home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / msdos / lynx / source / doslynx / src / turlvi12.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-25  |  2.8 KB  |  86 lines

  1. //    Copyright (c) 1993, University of Kansas, All Rights Reserved
  2. //
  3. //    Class:        TURLView
  4. //    Include File:    turlview.h
  5. //    Purpose:    Provide the view of a URL
  6. //    Remarks/Portability/Dependencies/Restrictions:
  7. //    Revision History:
  8. //        12-27-93    created
  9. //        02-02-94    Began a major revision to fully handle a
  10. //                multiple document interface with WWW, take
  11. //                over the formatting and drawing of the
  12. //                old gridtext functions of HText, and optimize
  13. //                memory usage, selecting anchors, the usage of
  14. //                HText's new image file.  See gridtext.
  15. //        02-09-94    Split all members into seperate files.
  16. #include"turlview.h"
  17.  
  18. unsigned short int TURLView::HTMLColor(signed long int sli_chars, unsigned
  19.     short int usi_colorindex)    {
  20. //    Purpose:    Take an offset into an HText stream and return
  21. //            an appropriate color with regards to fonts, anchors,
  22. //            and the video display mode.
  23. //    Arguments:    sli_chars    The offset into the HText stream.
  24. //            usi_colorindex    The offset into the palette entries
  25. //                    for the color for the video mode.
  26. //    Return Value:    unsigned short int    The color.
  27. //    Remarks/Portability/Dependencies/Restrictions:
  28. //        Bypassing TVision's color palettes for ease of configuation.
  29. //    Revision History:
  30. //        01-29-94    created
  31. //        04-04-94    Added a search color.
  32. //        04-20-94    Increased performance by not searching through
  33. //                all anchors all the time for a match.
  34.  
  35.     //    Go through the anchors, intelligently deciding if sli_chars
  36.     //    is within an anchor.
  37.     auto TextAttribute *TAp_check = NULL;
  38.  
  39.     //    First, check if there is search text to highlight.
  40.     if(TAp_search != NULL)    {
  41.         if(TAp_search->inRange(sli_chars) == 1)    {
  42.             //    Check to make sure that this is also not
  43.             //    the selected anchor.
  44.             if(TAp_selected != NULL)    {
  45.                 if(TAp_selected->inRange(sli_chars) == 1)
  46.                 {
  47.                     return(SearchSelectedColor);
  48.                 }
  49.             }
  50.             return(SearchColor);
  51.         }
  52.     }
  53.  
  54.     //    Start from the beginning index of the first anchor on possibly
  55.     //    on the screen already indexed by the draw function for us. If
  56.     //    our offset ever passes that of sli_chars, then consider that
  57.     //    it is not inside an anchor, but save this index until the
  58.     //    next time draw is called.
  59.     while(ssi_fasterpussycat < TNSCp_anchors->getCount())    {
  60.         //    Obtain the anchor.
  61.         TAp_check = (TextAttribute *)(TNSCp_anchors->at(
  62.             ssi_fasterpussycat));
  63.  
  64.         //    If already past what we are checking, break.
  65.         if(sli_chars < TAp_check->getBegin())    {
  66.             break;
  67.         }
  68.  
  69.         //    Next, determine if in the range of the anchor.
  70.         if(TAp_check->inRange(sli_chars) == 1)    {
  71.             //    Is this the selected anchor?
  72.             if(TAp_selected == TAp_check)    {
  73.                 return(SelectedColor);
  74.             }
  75.  
  76.             return(AnchorColor);
  77.         }
  78.  
  79.         //    Check the next one.
  80.         ssi_fasterpussycat++;
  81.     }
  82.  
  83.     //    not in any range, just display normally.
  84.     return(TextColor);
  85. }
  86.